package com.zh.demo04.controller;

import com.zh.demo04.common.ApiResult;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.UUID;

import static com.zh.demo04.common.ApiResult.success;


/**
 * 要权限才能访问
 *
 * @author ZH
 * @Date 12:31 2020/4/17
 */
@Slf4j
@RestController
@RequestMapping("/admin")
public class AdminController {

    @GetMapping("/category")
    public ApiResult<List<?>> categoryList(String sign) {
        log.info("call categoryList() ... sign = {}", sign);

        var xyj = new Category("西游类", "师徒四人西天取经");
        var sgyy = new Category("三国类", "三国之间的纷乱故事");
        var shz = new Category("水浒类", "一群好汉的江湖事迹");
        var hlm = new Category("红楼梦类", "晚清家族内部琐事");

        return success(List.of(xyj, sgyy, shz, hlm));
    }

    @Getter
    static class Category {
        private String id;
        private String name;
        private String remark;

        public Category() {
        }
        public Category(String name, String remark) {
            this.id = UUID.randomUUID().toString().substring(24);
            this.name = name;
            this.remark = remark;
        }
    }
}
